<%@ include file="/common/taglibs.jsp" %>

<head>
    <title><fmt:message key="activeUsers.title"/></title>
    <meta name="menu" content="AdminMenu"/>
    <script type="text/javascript" src="<c:url value='/dwr/interface/DwrService.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/dwr/engine.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/dwr/util.js'/>"></script>
</head>
<body id="activeUsers">

<div>
    <h2><fmt:message key="activeUsers.heading"/></h2>

    <p><fmt:message key="activeUsers.message"/></p>

    <div id="actions" class="form-actions">
        <a class="btn btn-primary" href="${ctx}/mainMenu" >
            <i class="icon-ok icon-white"></i> <fmt:message key="button.done"/>
        </a>
    </div>

    <display:table name="applicationScope.userNames" id="user" cellspacing="0" cellpadding="0"
                   defaultsort="1" class="table table-condensed table-striped table-hover" pagesize="50" requestURI="">
        <display:column titleKey="user.photo" style="width: 100px">
        	<c:choose>
        		<c:when test="${ user.loginType eq 'LDAP' }">
        			<img src="${ ctx }/thumbnailPhotoLdap?username=${ user.username }"/>
        		</c:when>
        		<c:when test="${ user.loginType eq 'INTERNAL' }">
        			<img src="${ ctx }/thumbnailPhoto?username=${ user.username }"/>
        		</c:when>
        	</c:choose>
        </display:column>  
        <display:column property="username" escapeXml="true" style="width: 10%" titleKey="user.username"
                        sortable="true"/>
        <display:column property="loginType" escapeXml="true" style="width: 10%" titleKey="user.loginType"   
                        sortable="true"/>
        <display:column titleKey="activeUsers.fullName" sortable="true">
            <c:out value="${user.fullName}" escapeXml="true"/>
            <c:if test="${not empty user.email}">
                <a href="mailto:<c:out value="${user.email}"/>">
                    <img width="16px" src="<c:url value="/images/iconEmail.png"/>"
                         alt="<fmt:message key="icon.email"/>" class="icon"/></a>
            </c:if>
        </display:column>
        <display:column style="width: 8%" titleKey="credenciales.actions">
			<a id="view" onclick="kickUser('${ user.username }')" class="topopup btn btn-danger">
				<i class="icon-remove icon-white"></i>
                <fmt:message key="button.kick"/>
			</a>
		</display:column>
        
        <display:setProperty name="paging.banner.item_name" value="user"/>
        <display:setProperty name="paging.banner.items_name" value="users"/>
    </display:table>
 
</div>

<script type="text/javascript">

function kickUser(username) {
	if(confirm('<fmt:message key="kick.are.you.sure" />'))
		DwrService.invalidateUserSession(username, {
								  callback:function(obj) {
									  if(obj == 'success') {										  
									  	alert('<fmt:message key="kick.success" />');
									  }
									  loadingoff();
								  }});
}

</script>
</body>